import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'home',
    meta: {
      title: '首页',
      // keepAlive: true,
      // requireAuth: false,
    },
    component: () => import('@/views/home.vue'),
  },
  {
    path: '/example',
    name: 'example',
    meta: {
      title: '例子',
    },
    component: () => import('@/views/example.vue'),
  },
  {
    path: '/vuemap',
    name: 'map',
    meta: {
      title: '地图',
    },
    component: () => import('@/views/vueMap.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

// 项目网页标题跟随路由变化
// router.beforeEach((to, from, next) => {
//   if (to.meta && to.meta.title) {
//     document.title = to.meta.title
//   }
//   next()
// })

export default router
